﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="NewsEdition.aspx.cs" Inherits="ankietyzacja.WebForm1" ValidateRequest="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
Edycja aktualności
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>
Edycja aktualności
</h2>    

    <asp:GridView ID="NewsGridView" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="AKTUALNOSCI_ID" 
        DataSourceID="AktualnosciEditSqlDataSource" ForeColor="#333333" 
        GridLines="None" 
        PageSize="5" ShowHeader="False" Width="731px">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
        
            <asp:TemplateField HeaderText="TRESC" SortExpression="TRESC">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("TRESC") %>' 
                        Height="267px" TextMode="MultiLine" Width="723px" CssClass="textEntry" ></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("DATAUTWORZENIA") %>' CssClass="bold"></asp:Label>
                    <br />
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("TRESC") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
<%--            <asp:CommandField CancelText="Anuluj" DeleteText="Usuń" EditText="Edytuj" 
                InsertText="Wstaw" NewText="Nowy" ShowEditButton="True" UpdateText="Zmień" ShowDeleteButton="True" DeleteImageUrl="img/delete.png" EditImageUrl="img/edit.png" ButtonType="Image" CancelImageUrl="img/cancel.png" UpdateImageUrl="img/ok.png" />
--%>            
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                        CommandName="Update" cssClass="commandLink" Text="Zmień"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" cssClass="commandLink" Text="Anuluj"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                     CommandName="Edit" cssClass="commandLink" Text="Edytuj"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Delete" cssClass="commandLink" OnClientClick="return confirm('Czy na pewno usunąć?')"    Text="Usuń"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>

        <EditRowStyle BackColor="#999999" />
        <EmptyDataTemplate>
            Brak aktualności.
        </EmptyDataTemplate>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Dodaj" 
        Width="180px" />
    <asp:TextBox ID="NewNewsTextBox" runat="server" Height="149px" 
    Width="914px" TextMode="MultiLine"></asp:TextBox>
    <asp:SqlDataSource ID="AktualnosciEditSqlDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ankietyzacjaConnectionString %>" 
        DeleteCommand="DELETE FROM [AKTUALNOSCI] WHERE [AKTUALNOSCI_ID] = @AKTUALNOSCI_ID" 
        InsertCommand="INSERT INTO [AKTUALNOSCI] ([DATAUTWORZENIA], [TRESC]) VALUES (GETDATE(), @TRESC)" 
        SelectCommand="SELECT * FROM [AKTUALNOSCI] ORDER BY [DATAUTWORZENIA] DESC" 
        UpdateCommand="UPDATE [AKTUALNOSCI] SET  [TRESC] = @TRESC WHERE [AKTUALNOSCI_ID] = @AKTUALNOSCI_ID">
        <DeleteParameters>
            <asp:Parameter Name="AKTUALNOSCI_ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="DATAUTWORZENIA" Type="DateTime" />
            <asp:Parameter Name="TRESC" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="DATAUTWORZENIA" Type="DateTime" />
            <asp:Parameter Name="TRESC" Type="String" />
            <asp:Parameter Name="AKTUALNOSCI_ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>
